@extends('layouts.public')

@section('bodyattr')class="gray-bg"@endsection

@section('body')
<style>
        .mask{
            position:fixed;
            top:0;
            bottom:0;
            left:0;
            right:0;
            z-index:1000;
            background: rgba(0,0,0,0.75);
            display: none;
        }
        .content{
            width:400px;
            height:250px;
            padding:30px 20px;
            background: #fff;
            border-radius: 5px;
            position:absolute;
            background: #fff;
            top:50%;
            left:50%;
            transform: translate(-50%,-50%);
        }
        .content h3{
            font-size:20px;
            padding:5px;
            text-align: center;
            color:#000;
        }
        .content p{
            font-size:12px;
            color:#333;
        }
        .item{
            line-height: 40px;
            display: flex;
        }
        .item span{
            color:#000;
        }
        .items{
            text-align: center;
        }
        .items .btn{
            margin:15px 10px;
        }
    </style>
    <div class="wrapper wrapper-content">
        <div class="row m-b">
            <div class="col-sm-12">
                <div class="tabs-container">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="{{route('admin.money.money_shen')}}">待审核列表</a></li>
                    </ul>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <form role="form" class="form-inline" method="get">
                            <div class="form-group">
                                <label class="sr-only">姓名</label>
                                <input type="text" name="title" placeholder="请输入姓名" class="form-control"
                                       value="{{request('title')}}">
                            </div>
                            <div class="form-group">
                                <label class="sr-only">手机号</label>
                                <input placeholder="手机号" class="form-control"  type="text"
                                       name="phone" value="{{request('phone')}}" style="width: 200px;"
                                       autocomplete="off">
                            </div>
                            <div class="form-group">
                                <label class="sr-only">银行卡号</label>
                                <input placeholder="银行卡号" class="form-control"  type="text"
                                       name="card_num" value="{{request('card_num')}}" style="width: 200px;"
                                       autocomplete="off">
                            </div>
                            <button type="submit" class="btn btn-primary">搜索</button>
                            <button type="button" class="btn btn-white"
                                    onclick="location.href='{{route('admin.order.orders')}}'">重置
                            </button>
                        </form>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <table class="table table-striped table-bordered table-hover dataTables-example dataTable">
                            <thead>
                            <tr role="row">
                                <th>提现ID</th>
                                <th>用户</th>
                                <th>姓名</th>
                                <th>电话</th>
                                <th>开户行</th>
                                <th>银行支行</th>
                                <th>银行卡号</th>
                                <th>账户金额</th>
                                <th>提现金额</th>
                                <th>状态</th>
                                <th>原因</th>
                                <th class="sorting" orderby="created_at">提现时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            @foreach($orders as $user)
                            <tr class="gradeA">
                                    <td>{{$user['id']}}</td>
                                    <td>{{$user['openid']}}</td>
                                    <td>{{$user['username']}}</td>
                                    <td>{{$user['phone']}}</td>
                                    <td>
                                        {{$user['card_type']}}
                                    </td>
                                    <td>
                                        {{$user['card_site']}}
                                    </td>
                                    <td>
                                        {{$user['card_num']}}
                                    </td>
                                    <td>{{$user['num']}}</td>
                                    <td>{{$user['money']}}</td>
                                    <td>
                                        @if($user['status']==4)
                                        <span style="color:green">已完成</span>
                                        @endif
                                        @if($user['status']==2)
                                        <span style="color:gray">已取消</span>
                                        @endif
                                        @if($user['status']==1)
                                        <span style="color:gray">进行中</span>
                                        @endif
                                    </td>
                                    <td>{{$user['refund_msg']}}</td>
                                    <td>{{$user['created_at']}}</td>
                                    <td>
                                    <a class="ajaxBtn btn btn-default exchange_btn" href="javascript:void(0);" id="{{$user['id']}}">驳回</a>  
                                    <a class="ajaxBtn btn btn-danger" href="javascript:void(0);" uri="{{route('admin.money.finish',[$user->id])}}" msg="通过审核后，该用户将需要您打款到他的账户，请确认是否通过该提现申请？">通过</a>
                                    </td>
                                </tr>
                            @endforeach
                        </table>
                        <div class="row">
                            <div class="col-sm-12">
                                <div>共 {{ $orders->total() }} 条记录</div>
                                {!! $orders->links() !!}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="mask">
                <div class="content">
                    <h3>提现审核页</h3>
                    <div class="item">
                        <input type="text" class="form-control" placeholder="请输入驳回原因" maxlength="30" id="code">
                    </div>
                    <div class="item items">
                        <div class="btn btn-default cancel">取消</div>
                        <div class="btn btn-primary" id="ok">确定</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection

@section('script')
    <script type="text/javascript" src="{{cdn('js/plugins/laydate/laydate.js')}}"></script>
    <script type="text/javascript">
        laydate.render({
            elem: '#created_at',
            range: true,
            max: 0
        });
        $(function(){
            $('.exchange_btn').click(function(){
                var id = $(this).attr('id');
                $('#code').val('');
                $('.mask').show();
                $('#ok').attr('data-id',id);
                $('.cancel').click(function () {
                    $('.mask').hide();
                })
                $('#ok').click(function(){
                    var code = $('#code').val();
                    var id =  $('#ok').attr('data-id');
                    if(code==''){
                        return layer.msg('驳回原因不能为空')
                    }
                    $.ajax({
                        url:'{{route("admin.money.money_refund")}}',
                        type:"post",
                        data:{
                            id:id,
                            refund_msg:code
                        },
                        success:function (res) {
                            if(res.status==1){
                                layer.msg('驳回成功');
                                $('.mask').hide();
                                setTimeout(()=>{
                                    window.location.reload()
                                },1000)
                            }else{
                                layer.msg(res.msg);
                            }
                        }
                    })
                })

            })
        })
    </script>

@endsection
